package appapi.service.impl;


import appapi.Vo.CardRecordDetailVo;
import appapi.Vo.CardRecordVo;
import appapi.dao.CarRecordMapper;
import appapi.entity.Zhongjiao.CardRecordPageReq;
import appapi.service.mango.CardRecordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author dhq
 * @version 1.0
 * @date 2023/9/13  14:05
 */
@Service
public class CardRecordServiceImpl implements CardRecordService {

    @Resource
    CarRecordMapper carRecordMapper;
    @Override
    public List<CardRecordVo> getCarRecordPageList(CardRecordPageReq cardRecordPageReq) {
        return carRecordMapper.getCarRecordPageList(cardRecordPageReq);
    }

    @Override
    public CardRecordDetailVo getDetail(String parkId) {
        CardRecordDetailVo detail = carRecordMapper.getDetail(parkId);
        //计算时长
        LocalDateTime startTime = detail.getStartTime();
        LocalDateTime endTime = detail.getEndTime();
        Duration duration = Duration.between(startTime,endTime);
        long minutes = duration.toMinutes();
        detail.setTime(minutes);
        return detail;
    }
}
